import axios from "../utils/request"
//登录
async function getLogin(params) {
    let { data } = await axios.post("login", params)
    return data
}
//左侧菜单
async function getleft(params) {
    let { data } = await axios.get("menus", { params })
    return data
}
//用户列表
async function getusers(params) {
    let { data } = await axios.get("users", params)
    return data
}
//添加用户接口
async function getadd(params) {
    let { data } = await axios.post("users", params)
    return data
}
//修改状态
async function getrevisechange(params) {
    let { data } = await axios.put(`users/${params.id}/state/${params.mg_state}`, params)
    return data
}
//修改
async function getrevise(params) {
    let { data } = await axios.put(`users/${params.id}`, params)
    return data
}

//删除
async function getdel(params) {
    let { data } = await axios.delete(`users/${params.id}`, params)
    return data
}

//搜索
async function getsearch(params) {
    let { data } = await axios.get(`users/${params.id}`, params)
    return data
}

//权限
async function getrights(params) {
    let { data } = await axios.get("rights/list", params)
    return data
}

// 角色列表请求
async function getroles(params) {
    let { data } = await axios.get("roles", params)
    return data
}

//添加角色
async function getaddrose(params) {
    let { data } = await axios.post("roles", params)
    return data

}

//修改角色
async function xgrevise(params) {
    let { data } = await axios.put(`roles/${params.id}`, params)
    return data

}

//删除角色
async function delroles(params) {
    let { data } = await axios.delete(`roles/${params.id}`, params)
    return data
}
//分配用户角色
async function getusersroles(params) {
    let { data } = await axios.put(`users/${params.id}/role`, params)
    return data
}
//分配权限删除
async function getdelx(params) {
    let { data } = await axios.delete(`roles/${params.roleId}/rights/${params.rightId}`, params)
    return data
}
//有所权限树状图
async function gettree(params) {
    let { data } = await axios.get("rights/tree", params)
    return data
}
//分配权限
async function getassing(params) {
    let { data } = await axios.post(`roles/${params.id}/rights`, params)
    return data
}
//商品分类数据列表
async function getshop(params) {
    let { data } = await axios.get("goods", { params })
    return data
}
//添加商品
async function getaddshop(params) {
    let { data } = await axios.post("goods", params)
    return data
}

//编辑商品
async function getreviseshop(params) {
    let { data } = await axios.put(`goods/${params.id}`, params)
    return data
}
//删除商品
async function getdelshop(params) {
    let { data } = await axios.delete(`goods/${params.id}`, params)
    return data
}
//商品分类列表
async function getclassify(params) {
    let { data } = await axios.get("categories", { params })
    return data
}

//商品添加
async function getcategories(params) {
    let { data } = await axios.post("categories", params)
    return data
}

//商品修改
async function getshopxg(params) {
    let { data } = await axios.put(`categories/${params.id}`, params)
    return data
}

//删除分类
async function getshodels(params) {
    let { data } = await axios.delete(`categories/${params.id}`, params)
    return data
}

//请求订单列表数据
async function getorders(params) {
    let { data } = await axios.get("orders", { params })
    return data
}

//请求地址接口
async function report(params) {
    let { data } = await axios.get("reports/type/1", { params })
    return data
}
//参数列表静态
async function attrib(params) {
    let { data } = await axios.get(`categories/${params.id}/attributes?sel=many`, { params })
    return data

}
//参数列表动态
async function attribo(params) {
    let { data } = await axios.get(`categories/${params.id}/attributes?sel=only`, { params })
    return data

}
//动态参数删除
async function delmany(params) {
    let { data } = await axios.delete(`categories/${params.id}/attributes/${params.attrid}`, { params })
    return data

}
//编辑提交参数
async function editmany(params) {
    let { data } = await axios.put(`categories/${params.cat_id}/attributes/${params.attr_id}`, params)
    return data

}

//添加动态参数
async function addmany(params) {
    let { data } = await axios.post(`categories/${params.cat_id}/attributes`, params)
    return data

}

//请求物流数据
async function ardds(params) {
    let { data } = await axios.get(`/kuaidi/${params.id}`, params)
    return data

}
export {
    getLogin,
    getleft,
    getusers, getadd,
    getrevisechange, getrevise, getdel, getsearch, getusersroles,
    getroles, getaddrose, xgrevise, delroles, gettree, getdelx,
    getrights, getassing,
    getshop, getaddshop, getreviseshop, getdelshop,
    getclassify, getcategories, getshopxg, getshodels,
    getorders,
    report, attrib, attribo, delmany, editmany,addmany,
    ardds

}